//
//  UILabel+Extensions.swift
//  MYModule
//
//  Created by 魔样科技 on 2022/11/11.
//

import Foundation

public extension UILabel {
    func adaptive(){
        self.numberOfLines = 0
        self.adjustsFontSizeToFitWidth = true
    }
    
    func setLabelFont(filterStrs: [String], font: UIFont){
        if let resultStr = self.text{
            let attrstring: NSMutableAttributedString = NSMutableAttributedString(string: resultStr)
            let str = NSString(string: resultStr)
            for subStr in filterStrs {
                if resultStr.contains(subStr){
                    let theRange = str.range(of: subStr)
                    attrstring.addAttribute(NSAttributedString.Key.font, value:font, range: theRange)
                    self.attributedText = attrstring
                }
            }
        }
    }
}
